package com.pro01.backend.service;

import com.pro01.backend.mapper.PromotionMapper;
import com.pro01.backend.pojo.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class PromotionService {

    @Autowired
    private PromotionMapper promotionMapper;

    public PageResult<Map<String, Object>> getPromotionHistory(int pageNum, int pageSize) {
        int offset = (pageNum - 1) * pageSize;
        List<Map<String, Object>> records = promotionMapper.getPromotionHistory(offset, pageSize);
        int total = promotionMapper.countPromotionHistory();

        return new PageResult<>(total, records);
    }
}
